package com.dao;

import com.pojo.Order;

import java.util.List;
import java.util.Map;

import com.pojo.OrderExample;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;

public interface OrderMapper {
    long countByExample(OrderExample example);

    int deleteByExample(OrderExample example);

    int deleteByPrimaryKey(Integer oId);

    int insert(Order record);

    int insertSelective(Order record);

    List<Order> selectByExample(OrderExample example);

    Order selectByPrimaryKey(Integer oId);

    int updateByExampleSelective(@Param("record") Order record, @Param("example") OrderExample example);

    int updateByExample(@Param("record") Order record, @Param("example") OrderExample example);

    int updateByPrimaryKeySelective(Order record);

    int updateByPrimaryKey(Order record);

    //自定义方法,获取所有关联数据
    public List<Order> selectAllOrderData();

    //获取带有表格的数据
    public  List<Order> selectByExampleWithTable(OrderExample example);

    //创建订单，自定义方法

    @Insert("INSERT INTO w_order (o_date, t_id, o_status, o_serial_no,diner_num) VALUE (#{oDate}, #{tId}, #{oStatus}, #{oSerialNo}, #{dinerNum})")
    @Options(useGeneratedKeys=true, keyProperty="oId", keyColumn="o_id")
    public Integer createOrder(Order order);

    //删除订单，
    public int deleteOrder(Order order);


    //根据id查询出带有orderitems的order
    public Order selectOrderWithItems(Integer oId);


    //根据订单状态查询订单列表
    public List<Order> selectOrderWithStatusMap(Map<String, Object> map);

    //挂单
    public int updateOrderStatus(Map<String, Object> map);


    //依靠订单的序列号寻找订单
    public Order selectOrderBySerialNo(String oSerialNo);


    //根据订单编号查询订单列表
    public  Order selectOrderByOid(Integer oId);

    //根据订单id查询总价和数量
    public Order selectPQbyOid(Integer oId);

    //根据订单状态查询带有orderitem的订单
    public List<Order> selectAllByOrderStatus(String oStatus);

    //查询具有特定结账日期的订单（非联级）
    public List<Order> selectOrderByDate(String oPayoffDate);

    public List<Order> selectOrderByDateAndDishType(Map<String, Object> map);

    //根据时间区间查询数据
    public List<Order> selectOrderByDateRange(Map<String, Object> map);
}